﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace SlQuery
{
    public class App : Application
    {
        public App()
        {
            Startup += new StartupEventHandler(App_Startup);
            Exit += new EventHandler(App_Exit);

            HtmlPage.RegisterScriptableObject("slQuery", this);
        }

        void App_Startup(object sender, StartupEventArgs e)
        {
            SlQuery.Get("tr").hover(OnMouseEnter, OnMouseLeave).click(OnClick);
        }

        void App_Exit(object sender, EventArgs e)
        {
        }

        public void OnClick(Object sender, EventArgs e)
        {
            SlQuery.Get(sender as HtmlElement).toggleClass("dark");
        }

        public void OnMouseEnter(Object sender, EventArgs e)
        {
            SlQuery.Get(sender as HtmlElement).addClass("hover");
        }

        public void OnMouseLeave(Object sender, EventArgs e)
        {
            SlQuery.Get(sender as HtmlElement).removeClass("hover");
        }

        [ScriptableMember]
        public void Delete()
        {
            SlQuery.Get("tr.dark").remove();
        }
    }
}
